//
//  MyTabBarController.m
//
//  Created by Detailscool on 16/2/17.
//  Copyright © 2016年 Detailscool. All rights reserved.
//

#import "MyTabBarController.h"
#import "MyNavigationViewController.h"

#import "HelloViewController.h"
#import "ExpressViewController.h"
#import "MessageViewController.h"
#import "MineViewController.h"

@interface MyTabBarController ()

@end

@implementation MyTabBarController
+ (void)initialize {
    
    // 获得全局TabBarItem
    UITabBarItem * tabBarItem = [UITabBarItem appearance];
    
    [tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],
                                         NSForegroundColorAttributeName:[UIColor lightGrayColor]} forState:UIControlStateNormal];
    [tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],
                                         NSForegroundColorAttributeName:RGBColor(69, 154, 64)} forState:UIControlStateSelected];
    
    UITabBar * tabBar = [UITabBar appearance];
    tabBar.tintColor = RGBColor(242, 242, 242);
}

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setupWith:[[HelloViewController alloc]init] title:@"hello" image:@"hello_icon" selectedImage:@"hello_icon_selected"];
    
    [self setupWith:[[ExpressViewController alloc]init] title:@"express" image:@"neighbor_collection" selectedImage:@"neighbor_collection_selected"];
    
    [self setupWith:[[MessageViewController alloc]init] title:@"message" image:@"msg_icon" selectedImage:@"msg_icon_selected"];
    
    [self setupWith:[[MineViewController alloc]initWithStyle:UITableViewStyleGrouped] title:@"mine" image:@"account"selectedImage:@"account_selected"];

}

- (void)setupWith:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage {
    
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
    
    [self addChildViewController:[[MyNavigationViewController alloc]initWithRootViewController:vc]];
}


@end
